package com.blahti.example.drag2;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;

import com.icons.draw.view.Geocoder;

import data.Coordinate;
import data.ParkingDB;

public class ReverseGeocodeLookupTask extends AsyncTask <Void, Void, String>
{
	private ProgressDialog dialog;
	protected DrawIcons applicationContext;
	protected OpenScreen drawIconContext;


	@Override
	protected void onPreExecute()
	{
		//this.dialog = ProgressDialog.show(applicationContext, "Please wait...contacting the tubes.",
			//	"Requesting reverse geocode lookup", true);
		//Toast.makeText (getApplicationContext(), "Please wait...contacting google", Toast.LENGTH_LONG).show ();
		Log.d("Reverse","Please wait...contacting google");
	}

	@Override
	protected String doInBackground(Void... params)
	{
		String localityName = "";
		ParkingDB parking_db = ParkingDB.getInstance();
		if (parking_db.curLoc != null)
		{
			Coordinate cord=new Coordinate(parking_db.curLoc.longitude,parking_db.curLoc.latitude);
			localityName = Geocoder.reverseGeocode(cord);
			Log.d("try","street is"+localityName);
			//Toast.makeText (getApplicationContext(), "Locality is: "+localityName, Toast.LENGTH_LONG).show ();
			parking_db.userStreet=localityName;
		}
		return "succes";
	}

	@Override
	protected void onPostExecute(String result)
	{
		//this.dialog.cancel();
		
	}
}
